#ifndef GRAPH_HPP
#define GRAPH_HPP

#include "edge.hpp"
#include "distribution.hpp"
#include <vector>
#include <iostream>

class graph_c
{
        typedef enum
        {
                UNDEFINED,
                EDGE,
                PEDGE,      
        } problem_type_e;

        typedef std::vector< edge_c * > edges_v;
        typedef std::vector< edges_v * > edges_v2;

        problem_type_e  problem_type;
        long            nodes_count;
        long            max_edges_count;
        double          density;
        edges_v *       edges;
        edges_v2 *      sorted_edges;
       
        graph_c ( long nodes_count, long max_edges_count, double density, problem_type_e problem_type );

        static graph_c *        parse_dimacs_problem    ( std::istream & dimacs_stream );
        static edge_c *         parse_dimacs_edge       ( std::istream & dimacs_stream, problem_type_e problem_type );

        bool    edge_already_exists     ( const edge_c * edge ) const;
        void    sort_edges              ();

public:
        ~graph_c        ( void );
        graph_c         ( const graph_c & right );
        

        static graph_c * parse_dimacs    ( std::istream & dimacs_stream );
        static graph_c * parse_dimacs    ( const char * file_path );
        static graph_c * generate_random ( long nodes_count, 
                                           long rigid_edges_count, 
                                           double density, 
                                           const distribution_i & probabilities_distribution );

        void             add_edge               ( edge_c * edge );
        const edge_c *   get_edge               ( long first_node_id, long second_node_id ) const;
        long             get_nodes_count        ( void ) const;
        long             get_edges_count        ( void ) const;
        long             get_max_edges_count    ( void ) const;
        void             store_dimacs           ( std::ostream & stream ) const;
        void             store_dimacs           ( const char * file_path ) const;
};

#endif

